<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <meta charset="utf-8" />
	<title>${sysName}</title>
	<meta name="description" content="TSP" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />

	<link rel="stylesheet" href="Content/js/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="Content/css/font-awesome.min.css">
    <link rel="stylesheet" href="Content/css/index.css">
    <link rel="stylesheet" href="Content/css/skins/_all-skins.css">
	
	<script src="Content/js/jquery/jQuery-2.2.0.min.js"></script>
    <script src="Content/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="Content/js/index.js"></script>
	
	<!--框架必需start-->
    <script src="stoneframe/scripts/plugins/cookie/jquery.cookie.js"></script>
    <link href="stoneframe/styles/learun-ui.css" rel="stylesheet" />
    <script src="stoneframe/scripts/utils/learun-ui.js"></script>
    <script src="stoneframe/scripts/plugins/dialog/dialog.js"></script>
    <script src="stoneframe/scripts/utils/learun-clientdata.js"></script>
    <!--框架必需end-->
    <!--即时通信start-->
    <link href="stoneframe/styles/learun-im.css" rel="stylesheet" />
    <script src="stoneframe/scripts/utils/learun-im.js"></script>
    <!--即时通信end-->
	<script>
        var contentPath = "";
    </script>
  </head>
  
  <body class="hold-transition skin-blue sidebar-mini" style="overflow:hidden;">
    <div id="ajax-loader" style="cursor: progress; position: fixed; top: -50%; left: -50%; width: 200%; height: 200%; background: #fff; z-index: 10000; overflow: hidden;">
        <img src="Content/img/ajax-loader.gif" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto;" />
    </div>
    <div class="wrapper">
        <!--头部信息-->
        <header class="main-header">
            <a href="javascript:void(0);" target="_blank" class="logo">
                <span class="logo-mini">TSP</span>
                <span class="logo-lg">TSP<strong>成为智能</strong></span>
            </a>
            <nav class="navbar navbar-static-top">
                <a class="sidebar-toggle">
                    <span class="sr-only">Toggle navigation</span>
                </a>
                <div class="navbar-custom-menu">
                    <ul class="nav navbar-nav">
                        <li class="dropdown messages-menu">
                            <!--<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="fa fa-envelope-o "></i>
                                <span class="label label-success">4</span>
                            </a>-->
                        </li>
                        <li class="dropdown notifications-menu">
                            <!--<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="fa fa-bell-o"></i>
                                <span class="label label-warning">10</span>
                            </a>-->
                        </li>
                        <li class="dropdown tasks-menu">
                            <!--<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="fa fa-flag-o"></i>
                                <span class="label label-danger">9</span>
                            </a>-->
                        </li>
                        <li class="dropdown user user-menu">
                            <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">
                                <!--<img src="Content/img/user2-160x160.jpg" id="userSex" class="user-image" alt="User Image">-->
                                <span class="hidden-xs" id="realName">admin</span>
                            </a>
                            <ul class="dropdown-menu pull-right">
                                <!--<li><a class="menuItem" data-id="userInfo" href="/SystemManage/User/Info"><i class="fa fa-user"></i>个人信息</a></li>-->
                                <li class="divider"></li>
                                <li><a href="logout.do"><i class="ace-icon fa fa-power-off"></i>安全退出</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
        <!--左边导航-->
        <div class="main-sidebar">
            <div class="sidebar">
                <div class="user-panel">
                    <div class="pull-left image">
                        <!--<img src="Content/img/user2-160x160.jpg" class="img-circle" alt="User Image">-->
                    </div>
                    <div class="pull-left info">
                        <a><i class="fa fa-circle text-success"></i><span id="realName1">管理员</span><span id="userName">admin</span></a>
                    </div>
                </div>
                <ul class="sidebar-menu" id="sidebar-menu">
                    <!--<li class="header">导航菜单</li>-->
                </ul>
            </div>
        </div>
        <!--中间内容-->
        <div id="content-wrapper" class="content-wrapper">
            <div class="content-tabs">
                <button class="roll-nav roll-left tabLeft">
                    <i class="fa fa-backward"></i>
                </button>
                <nav class="page-tabs menuTabs">
                    <div class="page-tabs-content" style="margin-left: 0px;">
                        <a href="javascript:void(0);;" class="menuTab active" data-id="welcome.do">欢迎首页</a>
                    </div>
                </nav>
                <button class="roll-nav roll-right tabRight">
                    <i class="fa fa-forward" style="margin-left: 3px;"></i>
                </button>
                <button class="roll-nav roll-right fullscreen"><i class="fa fa-arrows-alt"></i></button>
            </div>
            <div class="content-iframe" style="overflow: hidden;">
                <div class="mainContent" id="content-main" style="margin: 10px; margin-bottom: 0px; padding: 0;">
                    <iframe class="LRADMS_iframe" width="100%" height="100%" src="welcome.do" frameborder="0" data-id="welcome.do"></iframe>
                </div>
            </div>
        </div>
    </div>
    <!--聊天窗口start-->
    <a href="#" class="message-prompt" title="消息提醒"><i id="icon_message" class="fa fa-commenting"></i></a>
    <div class="message-wrap">
        <div class="message-content">
            <div class="message-header">
                企业内部微信
                <div class="message-close">
                    <a href="javascript:;">×</a>
                </div>
            </div>
            <div class="message-body">
                <div class="message-body-search">
                    <input type="text" class="search-text" placeholder="搜索：同事名称、讨论组名称">
                    <i class="fa fa-search"></i>
                </div>
                <div class="message-body-container">
                    <div class="message-nav" style="display: block;">
                        <ul>
                            <li id="nav-contact-tab" class="active">
                                <a title="联系人"><i class="fa fa-user"></i></a>
                            </li>
                            <li id="nav-group-tab">
                                <a title="讨论组"><i class="fa fa-users" style="font-size: 20px;"></i></a>
                            </li>
                            <li id="nav-last-tab">
                                <a title="最近回话"><i class="fa fa-comment"></i><span class="message-count">2</span></a>
                            </li>
                        </ul>
                    </div>
                    <div class="message-group" style="height: 335px; overflow: auto; overflow-x: hidden;">
                        <ul id="message-contact-list"></ul>
                        <ul id="message-group-list" class="message-chatlist" style="display: none;">
                            <div style="color: red;">目前不支持</div>
                        </ul>
                        <ul id="message-last-list" class="message-chatlist" style="display: none;">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="message-window">
        <div class="message-window-header">
            <span class="text">与 XXX 聊天中</span>
            <div class="close">
                <a href="javascript:;">×</a>
            </div>
        </div>
        <div class="message-window-chat" style="overflow: auto; height: 260px;">
            <div class="message-window-content" style="padding: 15px; height: auto; overflow: hidden;">
            </div>
        </div>
        <div class="message-window-tool">
            <a class="message-window-tool-seechatlog"><i class="fa fa-clock-o"></i>沟通记录</a>
        </div>
        <div class="message-window-send">
            <textarea autofocus placeholder="按回车发送消息,shift+回车换行"></textarea>
        </div>
    </div>
    <!--聊天窗口end-->
</body>
<script type="text/javascript">
//用于即时通讯（ 当前登录用户）
var user = "FH";	
var webSocket;
//在线总数
var userCount=0;
//用户列表
var userlist = "";
$(function () {
	$.ajax({
		url: "getUserInfo.do",
		type: "get",
		dataType: "json",
		async: false,
		success: function (data) {
			if(data.result=="0"){
				if(data.userInfo){
					$("#realName").html(data.userInfo.realName);
					$("#realName1").html(data.userInfo.realName);
					$("#userName").html(data.userInfo.userName);
					user=data.userInfo.realName+"("+data.userInfo.userName+")";
					online();
				}
			}
		}
	});
	
});

function online(){
	if(window.WebSocket){
		webSocket=new WebSocket("ws://"+oladdress);
		//连接成功
		webSocket.onopen=function(){
			webSocket.send("[join]"+user);
		}
		//连接失败
		webSocket.onerror=function(){
			
		}
		//连接断开
		webSocket.onclose=function(){
			
		}
		//消息接收
		webSocket.onmessage=function(message){
			var msg=JSON.parse(message.data);
			if(msg.type=="count"){
				userCount=msg.msg;
			}else if(msg.type=="goOut"){
				$("body").html("");
				goOut("此用户在其它终端已经早于您登录,您暂时无法登录");
			}else if(msg.type=="thegoout"){
				$("body").html("");
				goOut("您被系统管理员强制下线");
			}else if(msg.type=="changeMenu"){
				window.location.href=locat+'/main/yes';
			}else if(message.type == 'userlist'){
				userlist = message.list;
			}
		}
	}
}

function getUserCount(){
	websocket.send('[count]'+user);
	return userCount;
}

function getUserlist(){
	websocket.send('[getUserlist]'+user);
	return userlist;
}

//强制下线
function goOut(msg){
	alert(msg);
	window.location.href=locat+"/logout";
}

//强制某用户下线
function goOutUser(theuser){
	websocket.send('[goOut]'+theuser);
}
</script>
</html>
